using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class Quest
{
    public List<Objective> Objectives = new List<Objective>();
    public List<string> ChildsId = new List<string>();

    public string Id;

    bool Completed;
    public bool Active = false;
    bool Showable;

    public string Text;


    public Objective AddObjective(string id,
        int amount, string text, string info)
    {
        Objective objective = new Objective();
        objective.Id = id;
        objective.TotalAmount = amount;
        objective.Text = text;
        objective.AddionalInfo = info;

        Objectives.Add(objective);

        return objective;
    }
    public void SetParent(Quest parent)
    {
        parent.ChildsId.Add(this.Id);
    }

    public bool Check()
    {
        for (int i = 0; i < Objectives.Count; i++)
        {
            Objectives[i].Check();
        }
        for (int i = 0; i < Objectives.Count; i++)
        {
            if (!Objectives[i].Completed)
            {
                return false;
            }
        }
        Completed = true;

        //Debug.Log("Quest: " + Text + " Completed");
        return true;
    }
    public void SendInfo(string id, int value, string info)
    {
        for (int i = 0; i < Objectives.Count; i++)
        {
            Objectives[i].SendInfo(id, value, info);
        }
    }
}